﻿namespace DataServer.ApplicationLib.Controls
{
    public class ControlConfig
    {
        public static IDictionary<string, ControlBase> ControlDic = new Dictionary<string, ControlBase>();

        static ControlConfig()
        {
            RegisterControl();
        }

        private static void RegisterControl()
        {
            ControlDic[nameof(ControlTextBox)] = new ControlTextBox();
            ControlDic[nameof(ControlSelect)] = new ControlSelect();
            ControlDic[nameof(ControlNumeric)] = new ControlNumeric();
            ControlDic[nameof(ControlDate)] = new ControlDate();
        }

        public static ControlBase? GetControl(string controlType)
        {
            if (ControlDic.ContainsKey(controlType))
            {
                return ControlDic[controlType];
            }
            return null;
        }

    }
}
